﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ApiBetaSeries.Utils
{
    public class UtilsEnum
    {
        public static ShowStatus StringToShowStatus(string st)
        {
            try
            {
                return (ShowStatus)Enum.Parse(typeof(ShowStatus), st, true);
            }
            catch (Exception)
            {
                // if it fails, we just try this way (space in "On Hiatus");
                ShowStatus ret = ShowStatus.Other;
                if (st.Equals("On Hiatus", StringComparison.CurrentCultureIgnoreCase))
                    ret = ShowStatus.On_Hiatus;
                return ret;
            }

            
        }

        /// <summary>
        /// Get a SubtitleLanguage from a string
        /// </summary>
        /// <param name="lang">string of the language</param>
        /// <returns>The SubtitleLanguage</returns>
        public static SubtitleLanguage StringToSubtitleLanguage(string lang)
        {
            try
            {
                return (SubtitleLanguage) Enum.Parse(typeof(SubtitleLanguage), lang, true);
            }
            catch (Exception)
            {
                return SubtitleLanguage.Other;
            }
        }
            
    }
}
